Section 3.6.1.5.4
Using the Alpha Channel

Another way to specify non-filtered transmit transparency in an image map is by using the alpha channel .

PNG allows you to store a different transparency for each color index in the PNG file, if desired. If your paint programs support this feature of PNG, you can do the transparency editing within your paint program rather than specifying transmit values for each color in the POV file. Since PNG and TGA image formats can also store full alpha channel (transparency) information, you can generate image maps that have transparency which isn't dependent on the color of a pixel, but rather its location in the image.

Although POV uses transmit 0.0 to specify no transparency and 1.0 to specify full transparency, the alpha data ranges from 0 to 255 in the opposite direction. Alpha data 0 means the same as transmit 1.0 and alpha data 255 produces transmit 0.0.


Section 3.6.1.6
Quick Color

When developing POV-Ray scenes its often useful to do low quality test runs that render faster. The +Q command line switch can be used to turn off some time consuming color pattern and lighting calculations to speed things up. However all settings of +Q5 or lower turns off pigment calculations and creates gray objects.

By adding a "quick_color" to a pigment you tell POV-Ray what solid color to use for quick renders instead of a patterned pigment. For example:

pigment { gradient x color_map{ [0.0 color Yellow] [0.3 color Cyan] [0.6 color Magenta] [1.0 color Cyan] } turbulence 0.5 lambda 1.5 omega 0.75 octaves 8 quick_color Neon_Pink }

This tells POV-Ray to use solid Neon_Pink for test runs at quality +Q5 or lower but to use the turbulent gradient pattern for rendering at +Q6 and higher.

Note that solid color pigments such as

pigment {color Magenta}

automatically set the quick_color to that value. You may override this if you want. Suppose you have 10 spheres on the screen and all are Yellow. If you want to identify them individually you could give each a different quick_color like this:

sphere { <1,2,3>,4 pigment { color Yellow quick_color Red } } sphere { <-1,-2,-3>,4 pigment { color Yellow quick_color Blue } }

and so on. At +Q6 or higher they will all be Yellow but at +Q5 or lower each would be different colors so you could identify them.


Section 3.6.2
Normal

Ray tracing is known for the dramatic way it depicts reflection, refraction and lighting effects. Much of our perception depends on the reflective properties of an object. Ray tracing can exploit this by playing tricks on our perception to make us see complex details that aren't really there.

Suppose you wanted a very bumpy surface on the object. It would be very difficult to mathematically model lots of bumps. We can however simulate the way bumps look by altering the way light reflects off of the surface. Reflection calculations depend on a vector called a "surface normal" vector. This is a vector which points away from the surface and is perpendicular to it. By artificially modifying (or perturbing) this normal vector you can simulate bumps.

The normal {...} statement is the part of a texture which defines the pattern of normal perturbations to be applied to an object. Like the pigment statement, you can omit the surrounding texture block to save typing. Do not forget however that there is a texture implied. For example...

//this... //can be shortened to this... object { object { My_Object My_Object texture { pigment {color Purple} pigment {color Purple} normal {bumps 0.3} normal {bumps 0.3} } } }

Note that attaching a normal pattern does not really modify the surface. It only affects the way light reflects or refracts at the surface so that it looks bumpy.

The most complete form for defining a normal is as follows:

normal { NORMAL_IDENTIFIER PATTERN_TYPE FloatValue NORMAL_MODIFIERS TRANSFORMATIONS... }

Each of the items in a normal are optional but if they are present, they should be in the order shown above to insure that the results are as expected. Any items after the NORMAL_IDENTIFIER modify or override settings given in the identifier. If no identifier is specified then the items modify the normal values in the current default texture. The PATTERN_TYPE may optionally be followed by a float value that controls the apparent depth of the bumps. Typical values range from 0.0 to 1.0 but any value may be used. Negative values invert the pattern. The default value if none is specified is 0.5.

Valid NORMAL_MODIFIERS are slope_map, normal_map, bump_map and bump_size statements as well as any of the generic PATTERN_MODIFIERS such as translate, rotate, scale, turbulence, wave shape and warp statements. Such modifiers apply only to the normal and not to other parts of the texture. Modifiers should be specified last.

There are 3 basic types of NORMAL_PATTERN_TYPEs. They are pattern normals, specialized normals and bump_map. They differ in the types of modifiers you may use with them. Originally POV-Ray had some patterns which were exclusively used for pigments while others were exclusively used for normals. New in POV-Ray 3.0 you can use any pattern for either pigments or normals. For example it is now valid to use ripples as a pigment or wood as a normal type. The patterns bumps, dents, ripples, waves, wrinkles and bump_map were once exclusively normal patterns which could not be used as pigments. Because these 6 types use specialized normal modification calculations, they cannot have slope_map, normal_map or wave shape modifiers. All other normal pattern types may use them.


Section 3.6.2.1
Slope Maps

A slope_map is a normal pattern modifier which gives the user a great deal of control over the exact shape of the bumpy features. It is best illustrated with a gradient normal pattern. Suppose you have...

plane{z,0 pigment{White} normal {gradient x} }

this gives a ramp wave pattern that looks like small linear ramps that climb from the points at x=0 to x=1 and then abruptly drops to 0 again to repeat the ramp from x=1 to x=2. A slope_map turns this simple linear ramp into almost any wave shape you want. The syntax is as follows...

normal{ PATTERN_TYPE Value slope_map { [ NUM_1 POINT_SLOPE_1] [ NUM_2 POINT_SLOPE_2] [ NUM_3 POINT_SLOPE_3] ... } NORMAL_MODIFIERS... }

NOTE: the [] brackets are part of the actual statement. They are not notational symbols denoting optional parts. The brackets surround each entry in the slope map. There may be from 2 to 256 entries in the map.

The NUM_1, NUM_2... are float values between 0.0 and 1.0 inclusive. POINT_SLOPE_1, POINT_SLOPE__2... are 2 component vectors such as <0,1> where the first value represents the apparent height of the wave and the second value represents the slope of the wave at that point. The height should range between 0.0 and 1.0 but any value could be used.

The slope value is the change in height per unit of distance. For example a slope of zero means flat, a slope of 1.0 means slope upwards at a 45 degree angle, and a slope of -1 means slope down at 45 degrees. Theoretically a slope straight up would have infinite slope. In practice, slope values should be kept in the range -3.0 to +3.0. Keep in mind that this is only the visually apparent slope. A normal does not actually change the surface.

For example here is how to make the ramp slope up for the first half and back down on the second half creating a triangle wave with a sharp peak in the center.

normal { gradient x //this is the PATTERN_TYPE slope_map { [0 <0, 1>] // start at bottom and slope up [0.5 <1, 1>] // halfway through reach top still climbing [0.5 <1,-1>] // abruptly slope down [1 <0,-1>] // finish on down slope at bottom } }

The pattern function is evaluated and the result is a value from 0.0 to 1.0. The first entry says that at x=0, the apparent height is 0 and the slope is 1. At x=0.5 we are at height 1 and slope is still up at 1. The third entry also specifies that at x=0.5 (actually at some tiny fraction above 0.5) we have height 1 but slope -1 which is downwards. Finally at x=1 we are at height 0 again and still sloping down with slope -1.

Although this example connects the points using straight lines, the shape is actually a cubic spline. This example creates a smooth sine wave.

normal { gradient x //this is the PATTERN_TYPE slope_map { [0 <0.5, 1>] // start in middle and slope up [0.25 <1.0, 0>] // flat slope at top of wave [0.5 <0.5,-1>] // slope down at mid point [0.75 <0.0, 0>] // flat slope at bottom [1 <0.5, 1>] // finish in middle and slope up } }

This example starts at height 0.5 sloping up at slope 1. At a fourth of the way through we are at the top of the curve at height 1 with slope 0 which is flat. The space between these two is a gentle curve because the start and end slopes are different. At half way we are at half height sloping down to bottom out at 3/4ths. By the end we are climbing at slope 1 again to complete the cycle.

There are more examples in SLOPEMAP.POV in the sample scenes.

A slope_map may be used with any pattern except brick, checker, hexagon, bumps, dents, ripples, waves, wrinkles and bump_map.

You may declare and use slope_map identifiers. For example:

#declare Fancy_Wave= slope_map { // Now let's get fancy [0.0 <0, 1>] // Do tiny triangle here [0.2 <1, 1>] // down [0.2 <1,-1>] // to [0.4 <0,-1>] // here. [0.4 <0, 0>] // Flat area [0.5 <0, 0>] // through here. [0.5 <1, 0>] // Square wave leading edge [0.6 <1, 0>] // trailing edge [0.6 <0, 0>] // Flat again [0.7 <0, 0>] // through here. [0.7 <0, 3>] // Start scallop [0.8 <1, 0>] // flat on top [0.9 <0,-3>] // finish here. [0.9 <0, 0>] // Flat remaining through 1.0 } object{My_Object pigment{White} normal{ wood slope_map{Fancy_Wave} } }

Section 3.6.2.2
Normal Maps

Most of the time you will apply single normal pattern to an entire surface but you may also create a pattern or blend of normals using a normal_map. The syntax for a normal_map is identical to pigment_map except you specify a normal in each map entry.

A normal_map is specified by...

normal{ PATTERN_TYPE normal_map { [ NUM_1 NORMAL_BODY_1] [ NUM_2 NORMAL_BODY_2] [ NUM_3 NORMAL_BODY_3] ... } NORMAL_MODIFIERS... }

Where NUM_1, NUM_2... are float values between 0.0 and 1.0 inclusive. A NORMAL_BODY is anything that would normally appear inside a normal {...} statement but the normal keyword and {} braces are not needed. NOTE: the [] brackets are part of the actual statement. They are not notational symbols denoting optional parts. The brackets surround each entry in the map. There may be from 2 to 256 entries in the map.

For example,

normal { gradient x //this is the PATTERN_TYPE normal_map { [0.3 bumps scale 2] [0.3 dents] [0.6 dents] [0.9 marble turbulence 1] } }

When the gradient x function returns values from 0.0 to 0.3 then the scaled bumps normal is used. From 0.3 to 0.6 dents are From 0.6 up to 0.9 a blend of dents and a turbulent marble is used. From 0.9 on up only the turbulent marble is used.

Normal maps may be nested to any level of complexity you desire. The normals in a map may have slope_map or normal_maps or any type of normal you want.

A normal_map is also used with the average normal type. See "Average" for details.

Entire normals may also be used with the block patterns such as checker, hexagon and brick. For example...

normal { checker normal{gradient x scale .2} normal{gradient y scale .2} } }

Note that in the case of block patterns, the normal {...} wrapping is required around the normal information.

You may not use normal_map or individual normals with a bump_map. See "texture_map" for an alternative way to do this.


Section 3.6.2.3
Bump Maps

When all else fails and none of the above normal pattern types meets your needs, you can use a bump map to wrap a 2-D bit-mapped bump pattern around your 3-D objects.

Instead of placing the color of the image on the shape like an image_map, bump_map perturbs the surface normal based on the color of the image at that point. The result looks like the image has been embossed into the surface. By default, bump_map uses the brightness of the actual color of the pixel. Colors are converted to gray scale internally before calculating height. Black is a low spot, white is a high spot. The image's index values may be used instead (see use_index) below.


Section 3.6.2.3.1
Specifying a Bump Map

The syntax for bump_map is...

normal { bump_map { FILE_TYPE "filename" BITMAP_MODIFIERS... } NORMAL_MODIFIERS... }

Where FILE_TYPE is one of the following keywords gif, tga, iff, ppm, pgm, png, or sys. This is followed by the name of the file using any valid string expression. Several optional modifiers may follow the file specification. The modifiers are described below. Note: Earlier versions of POV-Ray allowed some modifiers before the FILE_TYPE but that syntax is being phased out in favor of the syntax described here.

Filenames specified in the bump_map statements will be searched for in the home (current) directory first, and if not found, will then be searched for in directories specified by any +L switches or Library_Path= options. This would facilitate keeping all your bump maps files in a separate subdirectory, and specifying a library path to them. Note that any operating system default paths are not searched unless you also specify them as a Library_Path.

By default, the bump pattern is mapped onto the X-Y plane. The bumps are "projected" onto the object as though there were a slide projector somewhere in the -Z direction. The bump pattern exactly fills the square area from x,y coordinates (0,0) to (1,1) regardless of the bitmaps's original size in pixels. If you would like to change this default, you may translate, rotate or scale the normal or texture to map it onto the object's surface as desired.

The file name is optionally followed by one or more BITMAP_MODIFIERS. The bump_size, use_color and use_index modifiers are specific to bump maps and are discussed in the following sections. See "bitmap modifiers" for other general bitmap modifiers.

After a bump_map statement but still inside the normal statement you may apply any legal normal modifiers except slope_map and pattern wave forms.


Next Section
Table Of Contents